package com.epoint.androidphone.mobileoa.ui.init;

import java.io.File;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;

import com.epoint.androidmobile.bizlogic.dbservice.ConfigKey;
import com.epoint.androidmobile.core.phoneutil.PhoneHelp;
import com.epoint.androidmobile.core.phoneutil.Service;
import com.epoint.androidphone.R;
import com.epoint.androidphone.mobileoa.ui.login.LoginView;
import com.epoint.androidphone.mobileoa.ui.superview.SuperPhonePage;

/**
 * @author liyc
 * @time @2013-5-5 下午11:42:21
 * @annomation 初始化页
 */
public class InitView extends SuperPhonePage{

	/**
	 * 附件下载路径
	 */
	public static String attachdownMainPath = "/sdcard/mobileoa/attachdownload/";

	/**
	 * 软件更新路径
	 */
	public static String updatenPath = "/sdcard/mobileoa/update/";

	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addContentViewAndTitle(R.layout.initview, "初始化页");
		getRlTopBar().setVisibility(View.GONE);
		
		String FrameDBPath = "data/data/%s/database/mobileoadb";
		FrameDBPath = String.format(FrameDBPath, PhoneHelp.getPackageName(this));
		File dbFile = new File(FrameDBPath);
		if(dbFile.exists())
		{
			System.out.println("数据库大小："+dbFile.length());
		}
		else{
			System.out.println("数据库不存在");
		}

		new Handler().postDelayed(new Runnable() {
			@Override
			public void run() {
				String webserviceurl = dbUtil.getConfigValue(ConfigKey.webserviceurl);
				if(webserviceurl.equals(""))
				{
					if(getString(R.string.WebServiceType).equals("1")){
						dbUtil.setConfigValue(ConfigKey.webserviceurl, getString(R.string.app_webservice_java));
					}
					else{
						dbUtil.setConfigValue(ConfigKey.webserviceurl, getString(R.string.app_webservice_dnet));
					}

				}
				Service.intentViewFinish(InitView.this, LoginView.class);
			}
		},1500);
	}
}
